rockchip/rk3399: Fix sram_udelay
authorDerek Basehore <[email protected]>
Fri, 6 Apr 2018 23:45:24 +0000 (16:45 -0700)
committerDerek Basehore <[email protected]>
Sat, 7 Apr 2018 00:24:11 +0000 (17:24 -0700)
This fixes an off by 576x bug the the sram_udelay code. The wrong
value was multipled by the system ticks per mhz value (which is 24),
so we delayed for 1/576th of the requested time.

Signed-off-by: Derek Basehore <[email protected]>
plat/rockchip/rk3399/drivers/dram/suspend.c

index f66150ae898acea304316b3fb5f4ff630c34932c..2a80bcb31b585b4818929845bb3f3021bbf68c60 100644 (file)
@@ -85,10 +85,11 @@ static __pmusramfunc uint32_t sram_get_timer_value(void)
 
 static __pmusramfunc void sram_udelay(uint32_t usec)
 {
-       uint32_t start, cnt, delta, delta_us;
+       uint32_t start, cnt, delta, total_ticks;
 
        /* counter is decreasing */
        start = sram_get_timer_value();
+       total_ticks = usec * SYS_COUNTER_FREQ_IN_MHZ;
        do {
                cnt = sram_get_timer_value();
                if (cnt > start) {
@@ -96,8 +97,7 @@ static __pmusramfunc void sram_udelay(uint32_t usec)
                        delta += start;
                } else
                        delta = start - cnt;
-               delta_us = (delta * SYS_COUNTER_FREQ_IN_MHZ);
-       } while (delta_us < usec);
+       } while (delta <= total_ticks);
 }
 
 static __pmusramfunc void configure_sgrf(void)